import { BaseWindow } from "../../../component/window/BaseWindow";
import { PageTool } from "../../../common/global/PageTool";
import { Language } from "../../../../extend/language/Language";
import { ObjCreate } from "../common/ObjCreate";
import { ImagesConst } from "../../resource/ImagesConst";
import { GImageBitmap } from "../../../../com/mui/controls/GImageBitmap";
import { TilePanel } from "../equipment/TilePanel";
import { ItemRenderer } from "./ItemRenderer";
import { PageSelecter } from "../common/pageSelect/PageSelecter";
import { DataProvider } from "../../../../fl/data/DataProvider";
//class SeekBuyItemPanel
    
    export  class SeekBuyItemPanel extends BaseWindow
    {
        constructor()
        {
            super();
            this._pageTool = new PageTool([], 35);
            setSize(238, 403);
            titleHeight = 30;
            title = Language.getString(31112);
            return;
        }

        protected /* override */ createChildren(): void
        {
            super.createChildren();
            this.init();
            return;
        }

        protected /* override */ createDisposedChildrenImpl(): void
        {
            super.createDisposedChildrenImpl();
            if (closeBtn) 
            {
                closeBtn.visible = false;
            }
            return;
        }

        /* internal  */init(): void
        {
            var loc1=ObjCreate.createBg(17, 40, 204, 315, this);
            ObjCreate.createBg(17, 38, 206, 25, this, ImagesConst.RbListHeader);
            addChild(new GImageBitmap("seekBuyTip.swf", 17, 45));
            this._itemListPanel = new TilePanel();
            this._itemListPanel.horizontalGap = 2;
            this._itemListPanel.verticalGap = 2;
            this._itemListPanel.columnWidth = 38;
            this._itemListPanel.rowHeight = 38;
            this._itemListPanel.columnCount = 5;
            this._itemListPanel.setSize(200, 282);
            this._itemListPanel.setStyle("cellRenderer", ItemRenderer);
            this._itemListPanel.move(18, 68);
            addChild(this._itemListPanel);
            this._pagebar = new PageSelecter();
            this._pagebar.mode = PageSelecter.SingleMode;
            this._pagebar.move(80, 360);
            this._pagebar.currentPage = 1;
            this._pagebar.addEventListener(flash.events.Event.CHANGE, this.onCurPageChangeHandler);
            addChild(this._pagebar);
            return;
        }

        public updateList(arg1: Array<any>): void
        {
            this._pageTool.array = arg1;
            this._pagebar.currentPage = 1;
            this._pagebar.maxPage = Math.ceil(arg1.length / 35);
            this.onCurPageChangeHandler();
            return;
        }

        /* internal  */onCurPageChangeHandler(arg1: Object /* flash.events.Event */=null): void
        {
            var loc1=this._pagebar.currentPage;
            var loc2=this._pageTool.getByPageNo(loc1);
            this._itemListPanel.dataProvider = new DataProvider(loc2);
            this._itemListPanel.selectedIndex = -1;
            this._itemListPanel.drawNow();
            return;
        }

        /* internal */ /* var */_itemListPanel: TilePanel;

        /* internal */ /* var */_pagebar: PageSelecter;

        /* internal */ /* var */_pageTool: PageTool;
    }
